package org.ccay.message.service;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.ccay.core.base.PageVO;
import org.ccay.core.base.PagedResult;
import org.ccay.core.exception.ApplicationException;
import org.ccay.message.PushMessageVO;

/**
 * 
 * 消息推送接口
 * @author chaowangbang
 * @since 2012-11-5
 */
@Path("")
@Produces("application/json")
public interface IPushMessageService {

	/**
	 * 根据条件查询消息
	 * 这个方法执行过后 所以获取的数据将被更新为已读3
	 * @param messageVO
	 * @param pageVO
	 * @return
	 * @throws ApplicationException Created：2012-10-19
	 * @author chaowangbang
	 */
	@GET
	@Path("list/page/{pageSize}/{curPage}")
	public PagedResult<PushMessageVO> usePagedMessageList(@QueryParam("") PushMessageVO messageVO, @PathParam("") PageVO pageVO)throws ApplicationException;

	/**
	 * 创建消息
	 * 
	 * @param pushMessageVO
	 * @return Created：2012-10-19
	 * @author chaowangbang
	 */
	@POST
	@Path("/single")
	public void createMessage(PushMessageVO messageVO)throws ApplicationException;

	/**
	 * 更具条件查询消息 不带分页
	 * 把消息变为已读
	 * @param messageVO
	 * @return Created：2012-10-19
	 * @author chaowangbang
	 */
	@GET
	@Path("/list")
	public List<PushMessageVO> useMessageList(@QueryParam("") PushMessageVO messageVO)throws ApplicationException;
	
	/**
	 * 更具条件查询消息 不带分页
	 * 把消息变为已读
	 * @param messageVO
	 * @return Created：2014-11-29
	 * @author chaowangbang
	 */
	@GET
	@Path("/pushlist")
	public List<PushMessageVO> usePushMessageList(@QueryParam("") PushMessageVO messageVO)throws ApplicationException;

	/**
	 * 删除消息
	 * 
	 * @param messageVO
	 * @return
	 * @throws ApplicationException Created：2012-10-19
	 * @author chaowangbang
	 */
	@PUT
	@Path("/d/single")
	public void deleteMessage(PushMessageVO messageVO) throws ApplicationException;

	/**
	 * 更新消息
	 * 
	 * @param pushMessageVO Created：2012-10-19
	 * @author chaowangbang
	 */
	@PUT
	@Path("/single")
	public void updateMessage(PushMessageVO messageVO)throws ApplicationException;
	
	/**
	 * 更新消息
	 * 
	 * @param pushMessageVO Created：2012-10-19
	 * @author chaowangbang
	 */
	@GET
	@Path("/update/read/{messageId}")
	public void updateMessageRead(@PathParam("messageId")Integer messageId)throws ApplicationException;
	
	/**
	 * 批量更新	
	 * @author chaowangbang
	 * @since 2012-11-9
	 * @param messageVOs
	 * @throws ApplicationException
	 */
	@PUT
	@Path("/list")
	public void updateMessageList(List<PushMessageVO> messageVOs) throws ApplicationException;
	
	/**
	 * 查询系统里面消息数量大于100的消息接收者
	 * @author chaowangbang
	 * @since 2012-12-24
	 * @return
	 * @throws ApplicationException
	 */
	public List<PushMessageVO> findUselessMessageList()throws ApplicationException;
	
	
	/**
	 * 删除某个用户消息大于100条的记录
	 * @author chaowangbang
	 * @since 2012-12-24
	 * @param messageVO
	 * @throws ApplicationException
	 */
	public void deleteUserMessage(PushMessageVO messageVO) throws ApplicationException;
	
	/**
	 * 发送异步消息
	 * @param messageVO
	 * @throws ApplicationException
	 * Created：2012-12-26
	 * @author chaowangbang
	 */
	public void  sendAsyncMessage(PushMessageVO messageVO);
	
	/**
	 * 删除系统里面用户消息大于100条的消息记录，按过期时间降序排序，快要过期的且消息num大于100的记录被删掉
	 * @author chaowangbang
	 * @since 2013-1-5
	 * @param messageVO
	 * @throws ApplicationException
	 */
	public void deleteUselessMessage() throws ApplicationException;
	
	/**
	 * 检查消息是否需要发送   和个性化关联
	 * @param messageType
	 * @return
	 * Created：2013-3-25
	 * @author chaowangbang
	 */
	public  boolean checkMessageEnable(String messageType);
	
	/**
	 * 查询未读的消息个数
	 * @param messageVO
	 * @param includeOverdue  是否包含过期的
	 * @return
	 * @author chaowangbang
	 */
	public int findNewMessageCount(PushMessageVO messageVO,boolean includeOverdue);
}
